﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain.zyy;
using MyMES.Error;
using MyMES.Writer.API.Application.CommendHandlers.BOMguans;
using MyMES.Writer.API.Application.Commends.BOMguans;

namespace MyMES.Writer.API.Controllers.BOMguans
{
    [Route("api/[controller]/[action]")]
    [ApiController]
   
    public class BOMguanController : ControllerBase
    {
        /// <summary>
        /// BOM管理
        /// </summary>
        private readonly IMediator med;

        public BOMguanController(IMediator med)
        {
            this.med = med;
        }
        /// <summary>
        /// 新增BOM管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<BOMguan>> AddBOMguans(AddBOMguancommand request, CancellationToken cancellationToken)
        {
            return await med.Send(request, cancellationToken);
        }
        /// <summary>
        /// 修改BOM管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]   
        public async Task<APIResult<BOMguan>> UpdateOMguans(UpdateBOMguancommand request, CancellationToken cancellationToken)
        {
           return await  med.Send(request,cancellationToken);
        }
    }
}
